/** layuiAdmin.std-v1.2.0 LPPL License By http://www.layui.com/admin/ */
 ;layui.define(["table","form"],function(e){
     var t=layui.$,i=layui.table;
     layui.form;
    var k= getCookie('kouling');
     if(k == ""){
         k=0;
         setCookie('kouling',k,7);
     }
     i.render({
         elem:"#LAY-user-manage",
         url:layui.setter.base+"json/useradmin/webuser.js",
         cols:[[{type:"checkbox",fixed:"left"},
             {field:"id",width:100,title:"ID",sort:!0},
             {field:"username",title:"用户名",minWidth:100},
             {field:"avatar",title:"头像",width:100,templet:"#imgTpl"},
             {field:"phone",title:"手机"},
             {field:"email",title:"邮箱"},
             {field:"sex",width:80,title:"性别"},
             {field:"ip",title:"IP"},
             {field:"jointime",title:"加入时间",sort:!0},
             {title:"操作",width:150,align:"center",
              fixed:"right",toolbar:"#table-useradmin-webuser"}]],
                page:!0,limit:30,height:"full-220",
         text:"对不起，加载出现异常！"}),

     i.on("tool(LAY-user-manage)",
             function(e){e.data;if("del"===e.event)layer.prompt({formType:1,title:"敏感操作，请验证口令"},
                 function(t,i){layer.close(i),
                     layer.confirm("真的删除行么",function(t){e.del(),
                         layer.close(t)})});else if("edit"===e.event){t(e.tr);
                         layer.open({type:2,title:"编辑用户",content:"__MODULE__/Admin/add",
                             maxmin:!0,area:["500px","450px"],
                             btn:["确定","取消"],
                             yes:function(e,t){
                             var l=window["layui-layer-iframe"+e],
                                 r="LAY-user-front-submit",n=t.find("iframe").contents().find("#"+r);
                             l.layui.form.on("submit("+r+")",
                                 function(t){t.field;
                                 i.reload("LAY-user-front-submit"),
                                     layer.close(e)}),n.trigger("click")},
                             success:function(e,t){}})}}),

         i.render({
             elem:"#LAY-user-back-manage",
             url:"getlist",
             cols:[[{type:"checkbox",fixed:"left"},
                 {field:"id",width:80,title:"ID",sort:!0},
                 {field:"name",width:80,title:"文章类别"},
                 {field:"title",title:"标题"},
                 {field:"titleimg",title:"图片",width:100,templet:"#imgTpl"},
                 {field:"source",title:"来源"},
                 {field:"readtimes",width:40,title:"点击量",sort:!0},
                 {field:"createtime",title:"发布时间",sort:!0},
                 {field:"istop",title:"是否推荐",templet:"#buttonIsTop",minWidth:60,align:"center",sort:!0},
                 {field:"isverify",title:"是否显示",templet:"#buttonIsVerify",minWidth:60,align:"center"},
                 {title:"操作",width:150,align:"center",fixed:"right",toolbar:"#table-useradmin-admin"}]],
             page:!0,limit:10,height:"full-220",
             text:"对不起，加载出现异常！"}),
         i.on("tool(LAY-user-back-manage)",
             function(e) {
                e.data;
                 if ("del" === e.event)
                 {
                     if(k >= 3){
                         return layer.msg('你已错误三次口令，已锁定，请联系管理员');
                     }
                     layer.prompt(
                     {
                         formType: 1,
                         title: "敏感操作，请验证口令"
                     },
                     function (t, i) {
                         /* layer.msg('请选择数据');*/
                         var id = e.data.id;
                         if (t == 'xiaoming' && k < 3) {
                             layer.close(i);
                             layer.confirm("确定删除此文章？",function(t){
                                 //执行 Ajax 后重载
                             layui.$.ajax({
                                     type:'get',
                                     dataType:"json",
                                     url:'delete/id/'+id,
                                     success:function (data) {
                                         if(data['st'] == 1){
                                             layer.msg(data['msg'], {icon: 1});
                                         }else {
                                             layer.msg(data['msg'], {icon: 2});
                                         }
                                         layui.table.reload("LAY-user-back-manage");
                                     },
                                     error:function () {
                                         layer.msg('删除失败', {icon: 2});
                                     }
                                 });
                                 layer.close(t);
                             });
                             k = 0;
                             setCookie('kouling', k, 7);
                         } else {
                             layer.close(i);
                             k++;
                             setCookie('kouling', k, 7);
                             layer.msg('口令错误三次将会被锁定', {icon: 2});
                         }
                     });
             }
             else if("edit"===e.event){
                 t(e.tr);
                 var id = e.data.id;
             layer.open({
                 type:2,
                 title:"编辑管理员",
                 content:"adminform/id/"+id,
                 area:["420px","460px"],
                 btn:["确定","取消"],
                 yes:function(e,t){
                     var l=window["layui-layer-iframe"+e],
                     r="LAY-user-back-submit",n=t.find("iframe").contents().find("#LAY-user-back-submit");
                 l.layui.form.on("submit(LAY-user-back-submit)",
                     function(s){
                     var dd = s.field;
                     //layer.msg('SDSD', {icon: 1});

                    layui.$.ajax({
                         type:'post',
                         dataType:"json",
                         data:dd,
                         url:'updatesave',
                         success:function (data) {
                                if(data['st'] == 1){
                                     layer.msg(data['msg'], {icon: 1});
                                }else {
                                    return layer.msg(data['msg'], {icon: 2});
                                }
                             layer.close(e);
                             i.reload("LAY-user-back-manage");
                             },
                         error:function () {
                             layer.msg('修改失败!', {icon: 2});
                         }
                     });
                 }),
                     n.trigger("click")
                 },
                 success:function(e,t){

                 }
             })
             }
         }),

         i.render({
             elem:"#LAY-user-back-role",
         url:layui.setter.base+"json/useradmin/role.js",
         cols:[[{type:"checkbox",fixed:"left"},
             {field:"id",width:80,title:"ID",sort:!0},
             {field:"rolename",title:"角色名"},
             {field:"limits",title:"拥有权限"},
             {field:"descr",title:"具体描述"},
             {title:"操作",width:150,align:"center",fixed:"right",toolbar:"#table-useradmin-admin"}]],
         text:"对不起，加载出现异常！"}),i.on("tool(LAY-user-back-role)",
         function(e){e.data;if("del"===e.event)layer.confirm("确定删除此角色？",
             function(t){e.del(),layer.close(t)});
         else if("edit"===e.event){t(e.tr);
         layer.open({type:2,title:"编辑角色",content:"__MODULE__/Role/add",area:["500px","480px"],btn:["确定","取消"],
             yes:function(e,t){var l=window["layui-layer-iframe"+e],r=t.find("iframe").contents().find("#LAY-user-role-submit");
             l.layui.form.on("submit(LAY-user-role-submit)",
                 function(t){t.field;i.reload("LAY-user-back-role"),
                     layer.close(e)}),r.trigger("click")},
             success:function(e,t){}})}}),e("useradmin",{})});